//
//  ViewController.m
//  SystemShareDemo
//
//  Created by Lucky on 15/9/13.
//  Copyright (c) 2015年 Lucky. All rights reserved.
//

#import "ViewController.h"
#import <Social/Social.h>

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    //1,判断分享服务是否可用
    
    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTencentWeibo]) {
        NSLog(@"true"); //可用
    }else{
        NSLog(@"false"); //不可用
        return;
    }
    
    //2,创建分享控制器
    
    SLComposeViewController *cvc = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTencentWeibo];
    
    [cvc setInitialText:@"测试分享"];
    
    [cvc addImage:[UIImage imageNamed:@"jkr"]];
    
    //3,弹出分享控制器
    
    [self presentViewController:cvc animated:YES completion:nil];
    
    //4,监听分享状态
    
    cvc.completionHandler = ^(SLComposeViewControllerResult result){
        if (result == SLComposeViewControllerResultDone) {
            NSLog(@"share completed!");
        }else{
            NSLog(@"share failure");
        }
    };
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
